home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / app / gimpsignal.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-29  |  4.4 KB  |  217 lines

  1. /* The GIMP -- an image manipulation program
  2.  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3.  *
  4.  * This program is free software; you can redistribute it and/or modify
  5.  * it under the terms of the GNU General Public License as published by
  6.  * the Free Software Foundation; either version 2 of the License, or
  7.  * (at your option) any later version.
  8.  *
  9.  * This program is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.  * GNU General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU General Public License
  15.  * along with this program; if not, write to the Free Software
  16.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17.  */
  18.  
  19. #include "gimpsignal.h"
  20.  
  21. struct _GimpSignalType
  22. {
  23.   GtkSignalMarshaller  marshaller;
  24.   GtkType              return_type;
  25.   guint                nparams;
  26.   const GtkType       *param_types;
  27. };
  28.  
  29. typedef const GtkType TypeArr[];
  30.  
  31. GimpSignalID
  32. gimp_signal_new (const gchar      *name,
  33.          GtkSignalRunType  signal_flags,
  34.          GtkType           object_type,
  35.          guint             function_offset,
  36.          GimpSignalType   *sig_type)
  37. {
  38.   return gtk_signal_newv (name,
  39.               signal_flags,
  40.               object_type,
  41.               function_offset,
  42.               sig_type->marshaller,
  43.               sig_type->return_type,
  44.               sig_type->nparams,
  45.               /* Bah. We try to be const correct, but 
  46.                  gtk isn't.. */
  47.               (GtkType *) sig_type->param_types);
  48. }
  49.  
  50.  
  51. /* void__void */
  52.  
  53. static GimpSignalType sigtype_void = 
  54. {
  55.   gtk_signal_default_marshaller,
  56.   GTK_TYPE_NONE,
  57.   0,
  58.   NULL
  59. };
  60.  
  61. GimpSignalType * const gimp_sigtype_void = &sigtype_void;
  62.  
  63.  
  64. /* void__pointer */
  65.  
  66. static void
  67. gimp_marshaller_pointer (GtkObject     *object,
  68.              GtkSignalFunc    func,
  69.              gpointer       func_data,
  70.              GtkArg        *args)
  71. {
  72.   (* (GimpHandlerPointer) func) (object,
  73.                  GTK_VALUE_POINTER (args[0]),
  74.                  func_data);
  75. }
  76.  
  77. static TypeArr pointer_types =
  78. {
  79.   GTK_TYPE_POINTER
  80. };
  81.  
  82. static GimpSignalType sigtype_pointer =
  83. {
  84.   gimp_marshaller_pointer,
  85.   GTK_TYPE_NONE,
  86.   1,
  87.   pointer_types
  88. };
  89.  
  90. GimpSignalType * const gimp_sigtype_pointer = &sigtype_pointer;
  91.  
  92.  
  93. /* void__int */
  94.  
  95. static void
  96. gimp_marshaller_int (GtkObject     *object,
  97.              GtkSignalFunc  func,
  98.              gpointer       func_data,
  99.              GtkArg        *args)
  100. {
  101.   (* (GimpHandlerInt) func) (object,
  102.                  GTK_VALUE_INT (args[0]),
  103.                  func_data);
  104. }
  105.  
  106. static TypeArr int_types =
  107. {
  108.   GTK_TYPE_INT
  109. };
  110.  
  111. static GimpSignalType sigtype_int =
  112. {
  113.   gimp_marshaller_int,
  114.   GTK_TYPE_NONE,
  115.   1,
  116.   int_types
  117. };
  118.  
  119. GimpSignalType* const gimp_sigtype_int = &sigtype_int;
  120.  
  121.  
  122. /* void__double */
  123.  
  124. static void
  125. gimp_marshaller_double (GtkObject     *object,
  126.             GtkSignalFunc  func,
  127.             gpointer       func_data,
  128.             GtkArg        *args)
  129. {
  130.   (* (GimpHandlerDouble) func) (object,
  131.                 GTK_VALUE_DOUBLE (args[0]),
  132.                 func_data);
  133. }
  134.  
  135. static TypeArr double_types =
  136. {
  137.   GTK_TYPE_DOUBLE
  138. };
  139.  
  140. static GimpSignalType sigtype_double =
  141. {
  142.   gimp_marshaller_double,
  143.   GTK_TYPE_NONE,
  144.   1,
  145.   double_types
  146. };
  147.  
  148. GimpSignalType* const gimp_sigtype_double = &sigtype_double;
  149.  
  150.  
  151. /* void__int_int_int */
  152.  
  153. static void
  154. gimp_marshaller_int_int_int (GtkObject     *object,
  155.                  GtkSignalFunc  func,
  156.                  gpointer       func_data,
  157.                  GtkArg        *args)
  158. {
  159.   (* (GimpHandlerIntIntInt) func) (object,
  160.                    GTK_VALUE_INT (args[0]),
  161.                    GTK_VALUE_INT (args[1]),
  162.                    GTK_VALUE_INT (args[2]),
  163.                    func_data);
  164. }
  165.  
  166. static TypeArr int_int_int_types =
  167. {
  168.   GTK_TYPE_INT,
  169.   GTK_TYPE_INT,
  170.   GTK_TYPE_INT
  171. };
  172.  
  173. static GimpSignalType sigtype_int_int_int =
  174. {
  175.   gimp_marshaller_int_int_int,
  176.   GTK_TYPE_NONE,
  177.   3,
  178.   int_int_int_types
  179. };
  180.  
  181. GimpSignalType* const gimp_sigtype_int_int_int = &sigtype_int_int_int;
  182.  
  183.  
  184. /* void__int_int_int_int */
  185.  
  186. static void
  187. gimp_marshaller_int_int_int_int (GtkObject     *object,
  188.                  GtkSignalFunc  func,
  189.                  gpointer       func_data,
  190.                  GtkArg        *args)
  191. {
  192.   (* (GimpHandlerIntIntIntInt) func) (object,
  193.                       GTK_VALUE_INT (args[0]),
  194.                       GTK_VALUE_INT (args[1]),
  195.                       GTK_VALUE_INT (args[2]),
  196.                       GTK_VALUE_INT (args[3]),
  197.                       func_data);
  198. }
  199.  
  200. static TypeArr int_int_int_int_types =
  201. {
  202.   GTK_TYPE_INT,
  203.   GTK_TYPE_INT,
  204.   GTK_TYPE_INT,
  205.   GTK_TYPE_INT
  206. };
  207.  
  208. static GimpSignalType sigtype_int_int_int_int =
  209. {
  210.   gimp_marshaller_int_int_int_int,
  211.   GTK_TYPE_NONE,
  212.   4,
  213.   int_int_int_int_types
  214. };
  215.  
  216. GimpSignalType * const gimp_sigtype_int_int_int_int = &sigtype_int_int_int_int;
  217.